Skip to content

process: add process.entrypoint - #64800

Open
avivkeller wants to merge 2 commits into
nodejs:mainfrom
avivkeller:process.entrypoint
Open

process: add process.entrypoint#64800
avivkeller wants to merge 2 commits into
nodejs:mainfrom
avivkeller:process.entrypoint

Conversation

@avivkeller

@avivkeller avivkeller commented Jul 28, 2026

Copy link
Copy Markdown
Member

Ref: #51840

Adds a process.entrypoint non-configurable property to the process object during bootstrap. This property reflects the executable's main entrypoint (i.e. not --require or --import-ed files, the main file).

Additionally, this entrypoint is passed to workers, so it reflects the entrypoint of the process that created the worker, not the entrypoint of the worker itself.

Signed-off-by: avivkeller <me@aviv.sh>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Jul 28, 2026
@avivkeller

Copy link
Copy Markdown
Member Author

@nodejs/process

@mcollina

Copy link
Copy Markdown
Member

in worker threadsx this is set to the entrypoint of the worker?

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (6a3d80f) to head (992b11a).
⚠️ Report is 44 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64800      +/-   ##
==========================================
- Coverage   90.16%   90.12%   -0.05%     
==========================================
  Files         744      744              
  Lines      242518   242571      +53     
  Branches    45705    45695      -10     
==========================================
- Hits       218670   218615      -55     
- Misses      15357    15443      +86     
- Partials     8491     8513      +22     
Files with missing lines Coverage Δ
lib/internal/main/worker_thread.js 94.46% <100.00%> (+0.11%) ⬆️
lib/internal/process/pre_execution.js 98.13% <100.00%> (+0.16%) ⬆️
lib/internal/worker.js 96.75% <100.00%> (+<0.01%) ⬆️

... and 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avivkeller

avivkeller commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

in worker threadsx this is set to the entrypoint of the worker?

This is set to the entrypoint of the process that created the worker, not the worker itself. So if /my/path/index.js creates /my/worker/index.js, entrypoint will a URL of /my/path/index.js.

@mcollina

Copy link
Copy Markdown
Member

in worker threadsx this is set to the entrypoint of the worker?

This is set to the entrypoint of the process that created the worker, not the worker itself. So if /my/path/index.js creates /my/worker/index.js, entrypoint will a URL of /my/path/index.js.

this is behaviorally different from the old "require.main".

Can we have the same?

@avivkeller

Copy link
Copy Markdown
Member Author

IMO it makes more sense to show the entrypoint of the process, not the worker

@mcollina

Copy link
Copy Markdown
Member

I'm saying this is not identical to require.main, or what import.main is defined.

The issue linked refers to require.main.

@avivkeller

Copy link
Copy Markdown
Member Author

Okay, I've changed Fixes to Ref, since I feel that it makes more sense to show it this way

@mcollina

mcollina commented Aug 1, 2026

Copy link
Copy Markdown
Member

Opened #64903 with the thread-scoped counterpart (module.entrypoint in node:module), matching require.main semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. review wanted PRs that need reviews.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants